﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MutableGrid : MonoBehaviour 
{
    public MapUnit mapUnit;
    public Map.MapType originType = Map.MapType.White;
    SpriteRenderer sp;
    public Sprite blackSprite;
    public Sprite whiteSprite;
    void Awake()
    {
        sp = GetComponent<SpriteRenderer>();
    }

    public void ReverseColor()
    {
        Map.MapType targetType = originType == Map.MapType.White ? Map.MapType.Black : Map.MapType.White;
        mapUnit.SwitchColor(targetType, false);
        if (targetType == Map.MapType.White)
        {
            ChangeSprite(whiteSprite);
        }
        else
        {
            ChangeSprite(blackSprite);
        }
    }
    void ChangeSprite(Sprite sprite)
    {
        sp.sprite = sprite;
    }

}